package com._901_惠科_QD_去重_;

import java.time.LocalDateTime;

public class PositionEntity {


    //    public boolean 比较XY_返回XY(Double before_X, Double before_Y, Double X_Sill, Double Y_Sill) {
    //接收XY
    //如果满足 【( 当前X 减 参数X ) <= X_阀值】&&【 (当前Y 减去 参数Y) <= Y阀值】
    //说明 当前记录属于无效记录，标签未被移动，不需要被保存
    //否则，需要被保存，并且把下次的
    //        return "100;200";
    //    }

    /**
     * 重写 hashCode 和 equals 用卡号去重(没用上)
     *
     * @return
     */
    //    @Override
    //    public int hashCode() {
    //        if (id != null) {
    //            return id.hashCode();
    //        }
    //        return super.hashCode();
    //    }
    //
    //    @Override
    //    public boolean equals(Object obj) {
    //        if (obj instanceof PositionEntity) {
    //            PositionEntity entity = (PositionEntity) obj;
    //            if (cardId != null) {
    //                return id.equals(entity.id);
    //            }
    //        }
    //        return super.equals(obj);

    private String id;//主键id自增
    private String cardId;//唯一标示id
    private Double cardX;//卡X坐标
    private Double cardY;//卡Y坐标
    private Double cardZ;//卡Z坐标
    private Double cardRelativeZ;//相对Z坐标
    private LocalDateTime time;//时间
    private String subnetId;//子网络ID
    private String floorId;//楼层ID
    private String uuid;//UUID

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public Double getCardX() {
        return cardX;
    }

    public void setCardX(Double cardX) {
        this.cardX = cardX;
    }

    public Double getCardY() {
        return cardY;
    }

    public void setCardY(Double cardY) {
        this.cardY = cardY;
    }

    public Double getCardZ() {
        return cardZ;
    }

    public void setCardZ(Double cardZ) {
        this.cardZ = cardZ;
    }

    public Double getCardRelativeZ() {
        return cardRelativeZ;
    }

    public void setCardRelativeZ(Double cardRelativeZ) {
        this.cardRelativeZ = cardRelativeZ;
    }

    public LocalDateTime getTime() {
        return time;
    }

    public void setTime(LocalDateTime time) {
        this.time = time;
    }

    public String getSubnetId() {
        return subnetId;
    }

    public void setSubnetId(String subnetId) {
        this.subnetId = subnetId;
    }

    public String getFloorId() {
        return floorId;
    }

    public void setFloorId(String floorId) {
        this.floorId = floorId;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }


    /**
     * 是否为有效数据
     *
     * @param beforeX 上一条数据的 X坐标
     * @param beforeY 上一条数据的 Y坐标
     * @param X_Sill  X_阀值
     * @param Y_Sill  Y_阀值
     * @return 是否为有效数据
     */
    public boolean isValid(Double beforeX, Double beforeY, Double X_Sill, Double Y_Sill) {
        //都等于0说明这是第一条数据
        if (beforeX == 0.0 && beforeY == 0.0) {
            return true;
        }

        //如果满足 【( 当前X 减 参数X ) < X_阀值】&&【 (当前Y 减去 参数Y) < Y阀值】,说明 当前记录属于无效记录，标签未被移动，不需要被保存 返回falsed
        //否则返回true
        if (getCardX() - beforeX < X_Sill && getCardY() - beforeY < Y_Sill) {
            return false;
        } else {
            return true;
        }
    }
}
